home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / xevious.c < prev    next >
Text File  |  2000-04-04  |  39KB  |  959 lines

  1. /***************************************************************************
  2.  
  3. Xevious
  4.  
  5. driver by Mirko Buffoni
  6.  
  7.  
  8. general map
  9. -----------+---+-----------------+-------------------------
  10.    hex     |r/w| D D D D D D D D |
  11.  location  |   | 7 6 5 4 3 2 1 0 | function
  12. -----------+---+-----------------+-------------------------
  13. 0000-3FFF  | R | D D D D D D D D | CPU 1 master rom (16k)
  14. 0000-1FFF  | R | D D D D D D D D | CPU 2 motion rom (8k)
  15. 0000-0FFF  | R | D D D D D D D D | CPU 3 sound  rom (4k)
  16. -----------+---+-----------------+-------------------------
  17. 6800-680F  | W | - - - - D D D D | Audio control
  18. 6810-681F  | W | - - - - D D D D | Audio control
  19. -----------+---+-----------------+-------------------------
  20. 6820       | W | - - - - - - - D | 0 = Reset IRQ1(latched)
  21. 6821       | W | - - - - - - - D | 0 = Reset IRQ2(latched)
  22. 6822       | W | - - - - - - - D | 0 = Reset NMI3(latched)
  23. 6823       | W | - - - - - - - D | 0 = Reset #2,#3 CPU
  24. -----------+---+-----------------+-------------------------
  25. 6830       | W |                 | watchdog reset
  26. -----------+---+-----------------+-------------------------
  27. 7000       |R/W| D D D D D D D D | custom 06 Data
  28. 7100       |R/W| D D D D D D D D | custom 06 Command
  29. 7???                               CPU #1 NMI REQUEST
  30. -----------+---+-----------------+-------------------------
  31. 7800-7FFF  |R/W| D D D D D D D D | 2k work ram
  32. -----------+---+-----------------+-------------------------
  33. 8000-87FF  |R/W| D D D D D D D D | 2k playfeild RAM
  34. -----------+---+-----------------+-------------------------
  35. 8000-877F  |R/W| D D D D D D D D | RAM
  36. 8780-87FF  |R/W| D D D D D D D D | 2k sprite RAM (X-POS)
  37. 9000-977F  |R/W| D D D D D D D D | RAM
  38. 9780-97FF  |R/W| D D D D D D D D | 2k sprite RAM (HSIZE,MODE ??)
  39. A000-A77F  |R/W| D D D D D D D D | RAM
  40. A780-A7FF  |R/W| D D D D D D D D | 2k sprite RAM (PIC)
  41. -----------+---+-----------------+-------------------------
  42. B000-BFFF  |R/W| D D D D D D D D | 4k playfeild RAM ( ATTRIB)
  43. C000-CFFF  |R/W| D D D D D D D D | 4k playfeild RAM ( PIC )
  44. -----------+---+-----------------+-------------------------
  45. D000-D00F  | W | D D D D D D D D | A0->D8:background Y scroll position
  46. D010-D01F  | W | D D D D D D D D | A0->D8:font Y scroll position ??
  47. D020-D02F  | W | D D D D D D D D | A0->D8:background X scroll position ??
  48. D030-D03F  | W | D D D D D D D D | A0->D8:font X scroll position ?
  49. D070-D07F  | W |               D | display flip mode ?
  50. -----------+---+-----------------+-------------------------
  51. F000       | W | D D D D D D D D | planet map position low ?
  52. F001       | W | D D D D D D D D | planet map position high ?
  53. F000       | R | D D D D D D D D | planet map data low ?
  54. F001       | R | D D D D D D D D | planet map data high ?
  55. -----------+---+-----------------+-------------------------
  56. Xevious memory map (preliminary)
  57.  
  58.   Z80-1:MASTER CPU
  59.     0000H-3FFFH R   P-ROM
  60.     4000H-FFFFH R/W shared area
  61.   Z80-2:MOTION CUP
  62.     0000H-1FFFH R   P-ROM
  63.     4000H-FFFFH R/W shared area
  64.   Z80-3:SOUND CPU
  65.     0000H-1FFFH R   P-ROM
  66.     4000H-FFFFH R/W shared area
  67.   shared area.
  68.     6800H-6807H R   DIP SWITCH READ
  69.                       A0-2 : bit select(6800H=bit0 , 6801=bit1,6807=bit7)
  70.                       D0   : DIP SW.A bit read
  71.                       D1   : DIP SW.B bit read
  72.                     DIP SW.A
  73.                       Bit0 = BLASTER SWITCH
  74.     6800H-680FH R   shadow(6800H-6807H)
  75.     6800H-681FH W   Sound RAM0 (same to DIGDUG ?)
  76.                       D0-3:data
  77.     6810H-681FH W   Sound RAM1
  78.                       D0-3:data
  79.     6820H       W   MASTER-INTERRUPT CLEAR & ENABLE
  80.                       D0 = 0:CLEAR & DISABLE / 1:ENABLE
  81.     6821H       W   MOTION-INTERRUPT CLEAR & ENABLE
  82.                       D0 = 0:CLEAR & DISABLE / 1:ENABLE
  83.     6822H       W   SOUND -NMI CONTROLL
  84.                       D0 = 0:NMI ON / 1:NMI OFF
  85.     6823H       W   CPU 2,3 RESET CONTROLL
  86.                       D0 = 0:RESET
  87.     6830H-683F  W   WDR Watch dock timer clear
  88.     6840H-6FFFH R/W shadow(6800H-603FH)
  89.     7000H       R   custom-io data read ( after CPU #1 NMI )
  90.     7000H       W   custom-io data write( after CPU #1 NMI )
  91.     7100H       R   custom-io timming port
  92.                      bit7  :1=busy ?
  93.                      bit6  :1=busy ?
  94.                      bit5  :1=busy ?
  95.     7100H       W   custom-io command write
  96.     7???H       W   sound ganarator (controll by custom_ic ?)
  97.     7800H-7FFFH R/W S-RAM
  98.     8000H-87FFh R/W ram ( master cpu )
  99.     8780H-87FFH R/W sprite X position ( 80-bf:used by master,c0-ff:used by motion)
  100.                       A0=0:sprite Y position (OFF = 0xef )
  101.                       A0=1:sprite X position
  102.     8800H-8FFFH R/W shadow(8000H-87FFH)
  103.     9000H-97FFH R/W ram ( motion cpu )
  104.     9780H-97FFH R/W sprite attribute
  105.                       A0=0:attribute Y
  106.                         bit0  :HSIZE  :sprite Y size ?
  107.                         bit1  :HUNDZ  :?
  108.                         bit2  :FLOP   :Y flip
  109.                         bit3  :HUKAIRS:?
  110.                         bit4-6:MD4-6  :?
  111.                         bit7  :BIT3   :select sprite set (0=4M,4P,4R 3bit:1=4N 2bit )
  112.                       A0=0:attribute X
  113.                         bit0  :HSIZE  :sprite X size ?
  114.                         bit1  :HUNDZ  :?
  115.                         bit2  :FLOP   :X flip
  116.                         bit3  :HUKAIRS:?
  117.                         bit4-6:MD4-6  :?
  118.                         bit7  :BIT3   :?
  119.     9800H-9FFFH R/W shadow(9000H-97FFH)
  120.     A000H-A7FFH R/W ram ( sound cpu , master cpu )
  121.     A780H-a7FFH R/W sprite character nnumber
  122.                       A0=0 character pattern name
  123.                       A0=1 color map select
  124.     A800H-AFFFH R/W shadow(A000H-A7FFH)
  125.     B000H-BFFFH R/W background attrivute ( have 2 scroll planes ? )
  126.                     D0-D1:COL0,1 palette set ?
  127.                     D1-D5:ANI0-3 color code  ?( font,bg use )
  128.                     D6   :ANF    X flip
  129.                     D7   :PFF    Y flip
  130.     C000H-CFFFH R/W background character ( have 2 scroll planes ? )
  131.     D000H-D07FH  W  CRTC access? (custom-13)
  132.     D???H        W  display flip select (TABLE 1P/2P mode)
  133.                       bit0  :FLIP
  134.     F000H        W  BS0 xevious planet map select low ?
  135.     F001H        W  BB1 xeviosu planet map select high ?
  136.     F000H        R  BB0 xevious planet map get low ?
  137.     F001H        R  BS1 xevious planet map get high ?
  138.     F002-FFFFH      shodow(F000H-F001H)
  139.  
  140. 3)schematic diagram block.
  141.  
  142.    Sheet 4A : main cpu , address decoder(4000h-7fffh) , sram
  143.    Sheet 4B : motion cpu
  144.    Sheet 5A : sound cpu
  145.    Sheet 5B : clock generator , 'digdug' sound , irq controller
  146.    Sheet 6A : joystick read , dip switch , audio(TONE?) , NMI to master cpu
  147.    Sheet 6B : address decoder (8000h-ffffh) , sprite ram r/w , disp. flip latch
  148.    Sheet 7A : sprite drawing engine
  149.    Sheet 7B : background ram , CRTC ?,graphic drawing engene ?
  150.    Sheet 8A : background(&font) drawing engene
  151.    Sheet 8B : display line buffer ?
  152.    Sheet 9A : video dac ( palette rom )
  153.    Sheet 9B : xevious planet map rom ?
  154.  
  155. P-ROMS in schematic
  156.  
  157. 1M  master cpu rom 0000H-1FFFH
  158. 1L  master cpu rom 2000H-3FFFH
  159. 4C  motion cpu rom 0000H-1FFFH
  160. 2C  sound  cpu rom 0000H-1FFFH
  161. 8M  sound pcm rom ?
  162. 6M  sound pcm decode rom ?
  163. 4M  spright pattern low (BIT3=0,000-127)
  164. 4P  spright pattern low (BIT3=0,128-255)
  165. 4R  spright pattern high(BIT3=0)
  166.       D0-3:000-127
  167.       D4-7:128-255
  168. 4N  spright pattern (BIT3=1)
  169. 3L  spright color map table
  170. 3M  spright color map table
  171. 3D  background pattern bit0
  172. 3C  background pattern bit1
  173. 3B  background font pattern
  174. 4H  background color map table
  175. 4F  background color map table
  176. 6E  palette rom blue
  177. 6D  palette rom green
  178. 6A  palette rom red
  179. 2A  xevious planet map table ??
  180. 2B  xevious planet map table ??
  181. 2C  xevious planet map table ??
  182.  
  183. S-RAMS in schematic
  184.  
  185. 1H  sram           7800H-7FFFH
  186. 7L  sound sram0    6800H-680FH
  187. 7K  sound sram1    6810H-681FH
  188. 2S  spright line   8000H-87FFH
  189. 2A  spright att    9000H-97FFH
  190. 2P  spright chr    A000H-A7FFH
  191. 2J  background ram B000H-B7FFH
  192. 2H  background ram B800H-BFFFH
  193. 2F  background ram C000H-C7FFH
  194. 2E  background ram C800H-CFFFH
  195. 5N,5M sprite display line buffer ? (even disp,odd draw)
  196. 6N,6M sprite display line buffer ? (even draw,odd disp)
  197.  
  198. *****************************************************************************/
  199.  
  200. #include "driver.h"
  201. #include "vidhrdw/generic.h"
  202.  
  203.  
  204. extern unsigned char *xevious_sharedram;
  205. READ_HANDLER( xevious_sharedram_r );
  206. WRITE_HANDLER( xevious_sharedram_w );
  207. READ_HANDLER( xevious_dsw_r );
  208. WRITE_HANDLER( xevious_interrupt_enable_1_w );
  209. WRITE_HANDLER( xevious_interrupt_enable_2_w );
  210. WRITE_HANDLER( xevious_interrupt_enable_3_w );
  211. WRITE_HANDLER( xevious_bs_w );
  212. READ_HANDLER( xevious_bb_r );
  213. READ_HANDLER( xevious_customio_r );
  214. READ_HANDLER( xevious_customio_data_r );
  215. WRITE_HANDLER( xevious_customio_w );
  216. WRITE_HANDLER( xevious_customio_data_w );
  217. WRITE_HANDLER( xevious_halt_w );
  218. int  xevious_interrupt_1(void);
  219. int  xevious_interrupt_2(void);
  220. int  xevious_interrupt_3(void);
  221. void xevious_init_machine(void);
  222.  
  223. WRITE_HANDLER( xevious_vh_latch_w );
  224.  
  225. extern unsigned char *xevious_fg_videoram,*xevious_fg_colorram;
  226. extern unsigned char *xevious_bg_videoram,*xevious_bg_colorram;
  227. WRITE_HANDLER( xevious_fg_videoram_w );
  228. WRITE_HANDLER( xevious_fg_colorram_w );
  229. WRITE_HANDLER( xevious_bg_videoram_w );
  230. WRITE_HANDLER( xevious_bg_colorram_w );
  231. int  xevious_vh_start( void );
  232. void xevious_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  233. void xevious_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  234.  
  235. WRITE_HANDLER( pengo_sound_w );
  236. extern unsigned char *pengo_soundregs;
  237.  
  238.  
  239.  
  240. static struct MemoryReadAddress readmem_cpu1[] =
  241. {
  242.     { 0x0000, 0x3fff, MRA_ROM },
  243.     { 0x6800, 0x6807, xevious_dsw_r },
  244.     { 0x7000, 0x700f, xevious_customio_data_r },
  245.     { 0x7100, 0x7100, xevious_customio_r },
  246.     { 0x7800, 0xcfff, xevious_sharedram_r },
  247.     { 0xf000, 0xffff, xevious_bb_r },
  248.     { -1 }    /* end of table */
  249. };
  250.  
  251. static struct MemoryReadAddress readmem_cpu2[] =
  252. {
  253.     { 0x0000, 0x1fff, MRA_ROM },
  254.     { 0x6800, 0x6807, xevious_dsw_r },
  255.     { 0x7800, 0xcfff, xevious_sharedram_r },
  256.     { 0xf000, 0xffff, xevious_bb_r },
  257.     { -1 }    /* end of table */
  258. };
  259.  
  260. static struct MemoryReadAddress readmem_cpu3[] =
  261. {
  262.     { 0x0000, 0x0fff, MRA_ROM },
  263.     { 0x7800, 0xcfff, xevious_sharedram_r },
  264.     { -1 }    /* end of table */
  265. };
  266.  
  267. static struct MemoryWriteAddress writemem_cpu1[] =
  268. {
  269.     { 0x0000, 0x3fff, MWA_ROM },
  270.     { 0x6820, 0x6820, xevious_interrupt_enable_1_w },
  271.     { 0x6821, 0x6821, xevious_interrupt_enable_2_w },
  272.     { 0x6822, 0x6822, xevious_interrupt_enable_3_w },
  273.     { 0x6823, 0x6823, xevious_halt_w },            /* reset controll */
  274.     { 0x6830, 0x683f, MWA_NOP },                /* watch dock reset */
  275.     { 0x7000, 0x700f, xevious_customio_data_w },
  276.     { 0x7100, 0x7100, xevious_customio_w },
  277.     { 0x7800, 0xafff, xevious_sharedram_w, &xevious_sharedram },
  278.     { 0xb000, 0xb7ff, xevious_fg_colorram_w, &xevious_fg_colorram },
  279.     { 0xb800, 0xbfff, xevious_bg_colorram_w, &xevious_bg_colorram },
  280.     { 0xc000, 0xc7ff, xevious_fg_videoram_w, &xevious_fg_videoram },
  281.     { 0xc800, 0xcfff, xevious_bg_videoram_w, &xevious_bg_videoram },
  282.     { 0xd000, 0xd07f, xevious_vh_latch_w }, /* ?? */
  283.     { 0xf000, 0xffff, xevious_bs_w },
  284.     { 0x8780, 0x87ff, MWA_RAM, &spriteram_2 },    /* here only */
  285.     { 0x9780, 0x97ff, MWA_RAM, &spriteram_3 },    /* to initialize */
  286.     { 0xa780, 0xa7ff, MWA_RAM, &spriteram, &spriteram_size },    /* the pointers */
  287.     { -1 }    /* end of table */
  288. };
  289.  
  290. static struct MemoryWriteAddress writemem_cpu2[] =
  291. {
  292.     { 0x0000, 0x1fff, MWA_ROM },
  293.     { 0x6830, 0x683f, MWA_NOP },                /* watch dog reset */
  294.     { 0x7800, 0xafff, xevious_sharedram_w },
  295.     { 0xb000, 0xb7ff, xevious_fg_colorram_w },
  296.     { 0xb800, 0xbfff, xevious_bg_colorram_w },
  297.     { 0xc000, 0xc7ff, xevious_fg_videoram_w },
  298.     { 0xc800, 0xcfff, xevious_bg_videoram_w },
  299.     { 0xd000, 0xd07f, xevious_vh_latch_w }, /* ?? */
  300.     { 0xf000, 0xffff, xevious_bs_w },
  301.     { -1 }    /* end of table */
  302. };
  303.  
  304. static struct MemoryWriteAddress writemem_cpu3[] =
  305. {
  306.     { 0x0000, 0x0fff, MWA_ROM },
  307.     { 0x6800, 0x681f, pengo_sound_w, &pengo_soundregs },
  308.     { 0x6822, 0x6822, xevious_interrupt_enable_3_w },
  309.     { 0x7800, 0xcfff, xevious_sharedram_w },
  310.     { -1 }    /* end of table */
  311. };
  312.  
  313.  
  314.  
  315. INPUT_PORTS_START( xevious )
  316.     PORT_START    /* DSW0 */
  317.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 )
  318.     PORT_DIPNAME( 0x02, 0x02, "Flags Award Bonus Life" )
  319.     PORT_DIPSETTING(    0x00, DEF_STR( No ) )
  320.     PORT_DIPSETTING(    0x02, DEF_STR( Yes ) )
  321.     PORT_DIPNAME( 0x0c, 0x0c, "Right Coin" )
  322.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_1C ) )
  323.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
  324.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_3C ) )
  325.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_6C ) )
  326.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
  327.     PORT_DIPNAME( 0x60, 0x60, DEF_STR( Difficulty ) )
  328.     PORT_DIPSETTING(    0x40, "Easy" )
  329.     PORT_DIPSETTING(    0x60, "Normal" )
  330.     PORT_DIPSETTING(    0x20, "Hard" )
  331.     PORT_DIPSETTING(    0x00, "Hardest" )
  332.     PORT_DIPNAME( 0x80, 0x80, "Freeze?" )
  333.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  334.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  335.  
  336.     PORT_START    /* DSW1 */
  337.     PORT_DIPNAME( 0x03, 0x03, "Left Coin" )
  338.     PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
  339.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
  340.     PORT_DIPSETTING(    0x00, DEF_STR( 2C_3C ) )
  341.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
  342.     /* TODO: bonus scores are different for 5 lives */
  343.     PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Bonus_Life ) )
  344.     PORT_DIPSETTING(    0x18, "10K 40K 40K" )
  345.     PORT_DIPSETTING(    0x14, "10K 50K 50K" )
  346.     PORT_DIPSETTING(    0x10, "20K 50K 50K" )
  347.     PORT_DIPSETTING(    0x0c, "20K 70K 70K" )
  348.     PORT_DIPSETTING(    0x08, "20K 80K 80K" )
  349.     PORT_DIPSETTING(    0x1c, "20K 60K 60K" )
  350.     PORT_DIPSETTING(    0x04, "20K 60K" )
  351.     PORT_DIPSETTING(    0x00, "None" )
  352.     PORT_DIPNAME( 0x60, 0x60, DEF_STR( Lives ) )
  353.     PORT_DIPSETTING(    0x40, "1" )
  354.     PORT_DIPSETTING(    0x20, "2" )
  355.     PORT_DIPSETTING(    0x60, "3" )
  356.     PORT_DIPSETTING(    0x00, "5" )
  357.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) )
  358.     PORT_DIPSETTING(    0x80, DEF_STR( Upright ) )
  359.     PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
  360.  
  361.     PORT_START    /* FAKE */
  362.     /* The player inputs are not memory mapped, they are handled by an I/O chip. */
  363.     /* These fake input ports are read by galaga_customio_data_r() */
  364.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
  365.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  366.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
  367.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
  368.     PORT_BIT_IMPULSE( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1, 1 )
  369.     PORT_BITX(0x20, IP_ACTIVE_LOW, IPT_BUTTON1, 0, IP_KEY_PREVIOUS, IP_JOY_PREVIOUS )
  370.     PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
  371.  
  372.     PORT_START    /* FAKE */
  373.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL)
  374.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL)
  375.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL)
  376.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL)
  377.     PORT_BIT_IMPULSE( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL, 1 )
  378.     PORT_BITX(0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL, 0, IP_KEY_PREVIOUS, IP_JOY_PREVIOUS )
  379.     PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
  380.  
  381.     PORT_START    /* FAKE */
  382.     PORT_BIT( 0x03, IP_ACTIVE_LOW, IPT_UNUSED )
  383.     PORT_BIT_IMPULSE( 0x04, IP_ACTIVE_LOW, IPT_START1, 1 )
  384.     PORT_BIT_IMPULSE( 0x08, IP_ACTIVE_LOW, IPT_START2, 1 )
  385.     PORT_BIT_IMPULSE( 0x10, IP_ACTIVE_LOW, IPT_COIN1, 1 )
  386.     PORT_BIT_IMPULSE( 0x20, IP_ACTIVE_LOW, IPT_COIN2, 1 )
  387.     PORT_BIT_IMPULSE( 0x40, IP_ACTIVE_LOW, IPT_COIN3, 1 )
  388.     PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
  389. INPUT_PORTS_END
  390.  
  391. /* same as xevious, the only difference is DSW0 bit 7 */
  392. INPUT_PORTS_START( xeviousa )
  393.     PORT_START    /* DSW0 */
  394.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 )
  395.     PORT_DIPNAME( 0x02, 0x02, "Flags Award Bonus Life" )
  396.     PORT_DIPSETTING(    0x00, DEF_STR( No ) )
  397.     PORT_DIPSETTING(    0x02, DEF_STR( Yes ) )
  398.     PORT_DIPNAME( 0x0c, 0x0c, "Right Coin" )
  399.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_1C ) )
  400.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
  401.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_3C ) )
  402.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_6C ) )
  403.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
  404.     PORT_DIPNAME( 0x60, 0x60, DEF_STR( Difficulty ) )
  405.     PORT_DIPSETTING(    0x40, "Easy" )
  406.     PORT_DIPSETTING(    0x60, "Normal" )
  407.     PORT_DIPSETTING(    0x20, "Hard" )
  408.     PORT_DIPSETTING(    0x00, "Hardest" )
  409.     /* when switch is on Namco, high score names are 10 letters long */
  410.     PORT_DIPNAME( 0x80, 0x80, "Copyright" )
  411.     PORT_DIPSETTING(    0x00, "Namco" )
  412.     PORT_DIPSETTING(    0x80, "Atari/Namco" )
  413.  
  414.     PORT_START    /* DSW1 */
  415.     PORT_DIPNAME( 0x03, 0x03, "Left Coin" )
  416.     PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
  417.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
  418.     PORT_DIPSETTING(    0x00, DEF_STR( 2C_3C ) )
  419.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
  420.     /* TODO: bonus scores are different for 5 lives */
  421.     PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Bonus_Life ) )
  422.     PORT_DIPSETTING(    0x18, "10K 40K 40K" )
  423.     PORT_DIPSETTING(    0x14, "10K 50K 50K" )
  424.     PORT_DIPSETTING(    0x10, "20K 50K 50K" )
  425.     PORT_DIPSETTING(    0x0c, "20K 70K 70K" )
  426.     PORT_DIPSETTING(    0x08, "20K 80K 80K" )
  427.     PORT_DIPSETTING(    0x1c, "20K 60K 60K" )
  428.     PORT_DIPSETTING(    0x04, "20K 60K" )
  429.     PORT_DIPSETTING(    0x00, "None" )
  430.     PORT_DIPNAME( 0x60, 0x60, DEF_STR( Lives ) )
  431.     PORT_DIPSETTING(    0x40, "1" )
  432.     PORT_DIPSETTING(    0x20, "2" )
  433.     PORT_DIPSETTING(    0x60, "3" )
  434.     PORT_DIPSETTING(    0x00, "5" )
  435.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) )
  436.     PORT_DIPSETTING(    0x80, DEF_STR( Upright ) )
  437.     PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
  438.  
  439.     PORT_START    /* FAKE */
  440.     /* The player inputs are not memory mapped, they are handled by an I/O chip. */
  441.     /* These fake input ports are read by galaga_customio_data_r() */
  442.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
  443.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  444.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
  445.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
  446.     PORT_BIT_IMPULSE( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1, 1 )
  447.     PORT_BITX(0x20, IP_ACTIVE_LOW, IPT_BUTTON1, 0, IP_KEY_PREVIOUS, IP_JOY_PREVIOUS )
  448.     PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
  449.  
  450.     PORT_START    /* FAKE */
  451.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL)
  452.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL)
  453.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL)
  454.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL)
  455.     PORT_BIT_IMPULSE( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL, 1 )
  456.     PORT_BITX(0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL, 0, IP_KEY_PREVIOUS, IP_JOY_PREVIOUS )
  457.     PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
  458.  
  459.     PORT_START    /* FAKE */
  460.     PORT_BIT( 0x03, IP_ACTIVE_LOW, IPT_UNUSED )
  461.     PORT_BIT_IMPULSE( 0x04, IP_ACTIVE_LOW, IPT_START1, 1 )
  462.     PORT_BIT_IMPULSE( 0x08, IP_ACTIVE_LOW, IPT_START2, 1 )
  463.     PORT_BIT_IMPULSE( 0x10, IP_ACTIVE_LOW, IPT_COIN1, 1 )
  464.     PORT_BIT_IMPULSE( 0x20, IP_ACTIVE_LOW, IPT_COIN2, 1 )
  465.     PORT_BIT_IMPULSE( 0x40, IP_ACTIVE_LOW, IPT_COIN3, 1 )
  466.     PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
  467. INPUT_PORTS_END
  468.  
  469. /* same as xevious, the only difference is DSW0 bit 7. Note that the bit is */
  470. /* inverted wrt xevious. */
  471. INPUT_PORTS_START( sxevious )
  472.     PORT_START    /* DSW0 */
  473.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 )
  474.     PORT_DIPNAME( 0x02, 0x02, "Flags Award Bonus Life" )
  475.     PORT_DIPSETTING(    0x00, DEF_STR( No ) )
  476.     PORT_DIPSETTING(    0x02, DEF_STR( Yes ) )
  477.     PORT_DIPNAME( 0x0c, 0x0c, "Right Coin" )
  478.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_1C ) )
  479.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
  480.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_3C ) )
  481.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_6C ) )
  482.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
  483.     PORT_DIPNAME( 0x60, 0x60, DEF_STR( Difficulty ) )
  484.     PORT_DIPSETTING(    0x40, "Easy" )
  485.     PORT_DIPSETTING(    0x60, "Normal" )
  486.     PORT_DIPSETTING(    0x20, "Hard" )
  487.     PORT_DIPSETTING(    0x00, "Hardest" )
  488.     PORT_DIPNAME( 0x80, 0x00, "Freeze?" )
  489.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  490.     PORT_DIPSETTING(    0x80, DEF_STR( On ) )
  491.  
  492.     PORT_START    /* DSW1 */
  493.     PORT_DIPNAME( 0x03, 0x03, "Left Coin" )
  494.     PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
  495.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
  496.     PORT_DIPSETTING(    0x00, DEF_STR( 2C_3C ) )
  497.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
  498.     /* TODO: bonus scores are different for 5 lives */
  499.     PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Bonus_Life ) )
  500.     PORT_DIPSETTING(    0x18, "10K 40K 40K" )
  501.     PORT_DIPSETTING(    0x14, "10K 50K 50K" )
  502.     PORT_DIPSETTING(    0x10, "20K 50K 50K" )
  503.     PORT_DIPSETTING(    0x0c, "20K 70K 70K" )
  504.     PORT_DIPSETTING(    0x08, "20K 80K 80K" )
  505.     PORT_DIPSETTING(    0x1c, "20K 60K 60K" )
  506.     PORT_DIPSETTING(    0x04, "20K 60K" )
  507.     PORT_DIPSETTING(    0x00, "None" )
  508.     PORT_DIPNAME( 0x60, 0x60, DEF_STR( Lives ) )
  509.     PORT_DIPSETTING(    0x40, "1" )
  510.     PORT_DIPSETTING(    0x20, "2" )
  511.     PORT_DIPSETTING(    0x60, "3" )
  512.     PORT_DIPSETTING(    0x00, "5" )
  513.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) )
  514.     PORT_DIPSETTING(    0x80, DEF_STR( Upright ) )
  515.     PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
  516.  
  517.     PORT_START    /* FAKE */
  518.     /* The player inputs are not memory mapped, they are handled by an I/O chip. */
  519.     /* These fake input ports are read by galaga_customio_data_r() */
  520.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
  521.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  522.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
  523.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
  524.     PORT_BIT_IMPULSE( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1, 1 )
  525.     PORT_BITX(0x20, IP_ACTIVE_LOW, IPT_BUTTON1, 0, IP_KEY_PREVIOUS, IP_JOY_PREVIOUS )
  526.     PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
  527.  
  528.     PORT_START    /* FAKE */
  529.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL)
  530.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL)
  531.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL)
  532.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL)
  533.     PORT_BIT_IMPULSE( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL, 1 )
  534.     PORT_BITX(0x20, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL, 0, IP_KEY_PREVIOUS, IP_JOY_PREVIOUS )
  535.     PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
  536.  
  537.     PORT_START    /* FAKE */
  538.     PORT_BIT( 0x03, IP_ACTIVE_LOW, IPT_UNUSED )
  539.     PORT_BIT_IMPULSE( 0x04, IP_ACTIVE_LOW, IPT_START1, 1 )
  540.     PORT_BIT_IMPULSE( 0x08, IP_ACTIVE_LOW, IPT_START2, 1 )
  541.     PORT_BIT_IMPULSE( 0x10, IP_ACTIVE_LOW, IPT_COIN1, 1 )
  542.     PORT_BIT_IMPULSE( 0x20, IP_ACTIVE_LOW, IPT_COIN2, 1 )
  543.     PORT_BIT_IMPULSE( 0x40, IP_ACTIVE_LOW, IPT_COIN3, 1 )
  544.     PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
  545. INPUT_PORTS_END
  546.  
  547.  
  548.  
  549. /* foreground characters */
  550. static struct GfxLayout charlayout =
  551. {
  552.     8,8,    /* 8*8 characters */
  553.     512,    /* 512 characters */
  554.     1,    /* 1 bit per pixel */
  555.     { 0 },
  556.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  557.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  558.     8*8    /* every char takes 8 consecutive bytes */
  559. };
  560. /* background tiles */
  561. static struct GfxLayout bgcharlayout =
  562. {
  563.     8,8,    /* 8*8 characters */
  564.     512,    /* 512 characters */
  565.     2,    /* 2 bits per pixel */
  566.     { 0, 512*8*8 },
  567.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  568.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  569.     8*8    /* every char takes 8 consecutive bytes */
  570. };
  571. /* sprite set #1 */
  572. static struct GfxLayout spritelayout1 =
  573. {
  574.     16,16,    /* 16*16 sprites */
  575.     128,    /* 128 sprites */
  576.     3,    /* 3 bits per pixel */
  577.     { 128*64*8+4, 0, 4 },
  578.     { 0, 1, 2, 3, 8*8+0, 8*8+1, 8*8+2, 8*8+3,
  579.             16*8+0, 16*8+1, 16*8+2, 16*8+3, 24*8+0, 24*8+1, 24*8+2, 24*8+3 },
  580.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  581.             32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8 },
  582.     64*8    /* every sprite takes 128 consecutive bytes */
  583. };
  584. /* sprite set #2 */
  585. static struct GfxLayout spritelayout2 =
  586. {
  587.     16,16,    /* 16*16 sprites */
  588.     128,    /* 128 sprites */
  589.     3,    /* 3 bits per pixel */
  590.     { 0, 128*64*8, 128*64*8+4 },
  591.     { 0, 1, 2, 3, 8*8+0, 8*8+1, 8*8+2, 8*8+3,
  592.             16*8+0, 16*8+1, 16*8+2, 16*8+3, 24*8+0, 24*8+1, 24*8+2, 24*8+3 },
  593.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  594.             32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8 },
  595.     64*8    /* every sprite takes 128 consecutive bytes */
  596. };
  597. /* sprite set #3 */
  598. static struct GfxLayout spritelayout3 =
  599. {
  600.     16,16,    /* 16*16 sprites */
  601.     64,    /* 64 sprites */
  602.     3,    /* 3 bits per pixel (one is always 0) */
  603.     { 64*64*8, 0, 4 },
  604.     { 0, 1, 2, 3, 8*8+0, 8*8+1, 8*8+2, 8*8+3,
  605.             16*8+0, 16*8+1, 16*8+2, 16*8+3, 24*8+0, 24*8+1, 24*8+2, 24*8+3 },
  606.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  607.             32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8 },
  608.     64*8    /* every sprite takes 64 consecutive bytes */
  609. };
  610.  
  611.  
  612.  
  613. static struct GfxDecodeInfo gfxdecodeinfo[] =
  614. {
  615.     { REGION_GFX1, 0x0000, &charlayout, 128*4+64*8,  64 },
  616.     { REGION_GFX2, 0x0000, &bgcharlayout,        0, 128 },
  617.     { REGION_GFX3, 0x0000, &spritelayout1,   128*4,  64 },
  618.     { REGION_GFX3, 0x2000, &spritelayout2,   128*4,  64 },
  619.     { REGION_GFX3, 0x6000, &spritelayout3,   128*4,  64 },
  620.     { -1 } /* end of array */
  621. };
  622.  
  623.  
  624.  
  625. static struct namco_interface namco_interface =
  626. {
  627.     3072000/32,    /* sample rate */
  628.     3,            /* number of voices */
  629.     100,        /* playback volume */
  630.     REGION_SOUND1    /* memory region */
  631. };
  632.  
  633. static const char *xevious_sample_names[] =
  634. {
  635.     "*xevious",
  636.     "explo1.wav",    /* ground target explosion */
  637.     "explo2.wav",    /* Solvalou explosion */
  638.     0    /* end of array */
  639. };
  640.  
  641. struct Samplesinterface samples_interface =
  642. {
  643.     1,    /* one channel */
  644.     80,    /* volume */
  645.     xevious_sample_names
  646. };
  647.  
  648.  
  649.  
  650. static struct MachineDriver machine_driver_xevious =
  651. {
  652.     /* basic machine hardware */
  653.     {
  654.         {
  655.             CPU_Z80,
  656.             3125000,    /* 3.125 Mhz (?) */
  657.             readmem_cpu1,writemem_cpu1,0,0,
  658.             xevious_interrupt_1,1
  659.         },
  660.         {
  661.             CPU_Z80,
  662.             3125000,    /* 3.125 Mhz */
  663.             readmem_cpu2,writemem_cpu2,0,0,
  664.             xevious_interrupt_2,1
  665.         },
  666.         {
  667.             CPU_Z80,
  668.             3125000,    /* 3.125 Mhz */
  669.             readmem_cpu3,writemem_cpu3,0,0,
  670.             xevious_interrupt_3,2
  671.         }
  672.     },
  673.     60, DEFAULT_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  674.     100,    /* 100 CPU slices per frame - an high value to ensure proper */
  675.             /* synchronization of the CPUs */
  676.     xevious_init_machine,
  677.  
  678.     /* video hardware */
  679.     36*8, 28*8, { 0*8, 36*8-1, 0*8, 28*8-1 },
  680.     gfxdecodeinfo,
  681.     128+1,128*4+64*8+64*2,
  682.     xevious_vh_convert_color_prom,
  683.  
  684.     VIDEO_TYPE_RASTER,
  685.     0,
  686.     xevious_vh_start,
  687.     0,
  688.     xevious_vh_screenrefresh,
  689.  
  690.     /* sound hardware */
  691.     0,0,0,0,
  692.     {
  693.         {
  694.             SOUND_NAMCO,
  695.             &namco_interface
  696.         },
  697.         {
  698.             SOUND_SAMPLES,
  699.             &samples_interface
  700.         }
  701.     }
  702. };
  703.  
  704.  
  705.  
  706. /***************************************************************************
  707.  
  708.   Game driver(s)
  709.  
  710. ***************************************************************************/
  711.  
  712. ROM_START( xevious )
  713.     ROM_REGION( 0x10000, REGION_CPU1 )    /* 64k for the first CPU */
  714.     ROM_LOAD( "xvi_1.3p",     0x0000, 0x1000, 0x09964dda )
  715.     ROM_LOAD( "xvi_2.3m",     0x1000, 0x1000, 0x60ecce84 )
  716.     ROM_LOAD( "xvi_3.2m",     0x2000, 0x1000, 0x79754b7d )
  717.     ROM_LOAD( "xvi_4.2l",     0x3000, 0x1000, 0xc7d4bbf0 )
  718.  
  719.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for the second CPU */
  720.     ROM_LOAD( "xvi_5.3f",     0x0000, 0x1000, 0xc85b703f )
  721.     ROM_LOAD( "xvi_6.3j",     0x1000, 0x1000, 0xe18cdaad )
  722.  
  723.     ROM_REGION( 0x10000, REGION_CPU3 )    /* 64k for the audio CPU */
  724.     ROM_LOAD( "xvi_7.2c",     0x0000, 0x1000, 0xdd35cf1c )
  725.  
  726.     ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  727.     ROM_LOAD( "xvi_12.3b",    0x0000, 0x1000, 0x088c8b26 )    /* foreground characters */
  728.  
  729.     ROM_REGION( 0x2000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  730.     ROM_LOAD( "xvi_13.3c",    0x0000, 0x1000, 0xde60ba25 )    /* bg pattern B0 */
  731.     ROM_LOAD( "xvi_14.3d",    0x1000, 0x1000, 0x535cdbbc )    /* bg pattern B1 */
  732.  
  733.     ROM_REGION( 0x8000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  734.     ROM_LOAD( "xvi_15.4m",    0x0000, 0x2000, 0xdc2c0ecb )    /* sprite set #1, planes 0/1 */
  735.     ROM_LOAD( "xvi_18.4r",    0x2000, 0x2000, 0x02417d19 )    /* sprite set #1, plane 2, set #2, plane 0 */
  736.     ROM_LOAD( "xvi_17.4p",    0x4000, 0x2000, 0xdfb587ce )    /* sprite set #2, planes 1/2 */
  737.     ROM_LOAD( "xvi_16.4n",    0x6000, 0x1000, 0x605ca889 )    /* sprite set #3, planes 0/1 */
  738.     /* 0xa000-0xafff empty space to decode sprite set #3 as 3 bits per pixel */
  739.  
  740.     ROM_REGION( 0x4000, REGION_GFX4 )    /* background tilemaps */
  741.     ROM_LOAD( "xvi_9.2a",     0x0000, 0x1000, 0x57ed9879 )
  742.     ROM_LOAD( "xvi_10.2b",    0x1000, 0x2000, 0xae3ba9e5 )
  743.     ROM_LOAD( "xvi_11.2c",    0x3000, 0x1000, 0x31e244dd )
  744.  
  745.     ROM_REGION( 0x0b00, REGION_PROMS )
  746.     ROM_LOAD( "xvi_8bpr.6a",  0x0000, 0x0100, 0x5cc2727f ) /* palette red component */
  747.     ROM_LOAD( "xvi_9bpr.6d",  0x0100, 0x0100, 0x5c8796cc ) /* palette green component */
  748.     ROM_LOAD( "xvi10bpr.6e",  0x0200, 0x0100, 0x3cb60975 ) /* palette blue component */
  749.     ROM_LOAD( "xvi_7bpr.4h",  0x0300, 0x0200, 0x22d98032 ) /* bg tiles lookup table low bits */
  750.     ROM_LOAD( "xvi_6bpr.4f",  0x0500, 0x0200, 0x3a7599f0 ) /* bg tiles lookup table high bits */
  751.     ROM_LOAD( "xvi_4bpr.3l",  0x0700, 0x0200, 0xfd8b9d91 ) /* sprite lookup table low bits */
  752.     ROM_LOAD( "xvi_5bpr.3m",  0x0900, 0x0200, 0xbf906d82 ) /* sprite lookup table high bits */
  753.  
  754.     ROM_REGION( 0x0200, REGION_SOUND1 )    /* sound PROMs */
  755.     ROM_LOAD( "xvi_2bpr.7n",  0x0000, 0x0100, 0x550f06bc )
  756.     ROM_LOAD( "xvi_1bpr.5n",  0x0100, 0x0100, 0x77245b66 )    /* timing - not used */
  757. ROM_END
  758.  
  759. ROM_START( xeviousa )
  760.     ROM_REGION( 0x10000, REGION_CPU1 )    /* 64k for the first CPU */
  761.     ROM_LOAD( "xea-1m-a.bin", 0x0000, 0x2000, 0x8c2b50ec )
  762.     ROM_LOAD( "xea-1l-a.bin", 0x2000, 0x2000, 0x0821642b )
  763.  
  764.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for the second CPU */
  765.     ROM_LOAD( "xea-4c-a.bin", 0x0000, 0x2000, 0x14d8fa03 )
  766.  
  767.     ROM_REGION( 0x10000, REGION_CPU3 )    /* 64k for the audio CPU */
  768.     ROM_LOAD( "xvi_7.2c",     0x0000, 0x1000, 0xdd35cf1c )
  769.  
  770.     ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  771.     ROM_LOAD( "xvi_12.3b",    0x0000, 0x1000, 0x088c8b26 )    /* foreground characters */
  772.  
  773.     ROM_REGION( 0x2000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  774.     ROM_LOAD( "xvi_13.3c",    0x0000, 0x1000, 0xde60ba25 )    /* bg pattern B0 */
  775.     ROM_LOAD( "xvi_14.3d",    0x1000, 0x1000, 0x535cdbbc )    /* bg pattern B1 */
  776.  
  777.     ROM_REGION( 0x8000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  778.     ROM_LOAD( "xvi_15.4m",    0x0000, 0x2000, 0xdc2c0ecb )    /* sprite set #1, planes 0/1 */
  779.     ROM_LOAD( "xvi_18.4r",    0x2000, 0x2000, 0x02417d19 )    /* sprite set #1, plane 2, set #2, plane 0 */
  780.     ROM_LOAD( "xvi_17.4p",    0x4000, 0x2000, 0xdfb587ce )    /* sprite set #2, planes 1/2 */
  781.     ROM_LOAD( "xvi_16.4n",    0x6000, 0x1000, 0x605ca889 )    /* sprite set #3, planes 0/1 */
  782.     /* 0xa000-0xafff empty space to decode sprite set #3 as 3 bits per pixel */
  783.  
  784.     ROM_REGION( 0x4000, REGION_GFX4 )    /* background tilemaps */
  785.     ROM_LOAD( "xvi_9.2a",     0x0000, 0x1000, 0x57ed9879 )
  786.     ROM_LOAD( "xvi_10.2b",    0x1000, 0x2000, 0xae3ba9e5 )
  787.     ROM_LOAD( "xvi_11.2c",    0x3000, 0x1000, 0x31e244dd )
  788.  
  789.     ROM_REGION( 0x0b00, REGION_PROMS )
  790.     ROM_LOAD( "xvi_8bpr.6a",  0x0000, 0x0100, 0x5cc2727f ) /* palette red component */
  791.     ROM_LOAD( "xvi_9bpr.6d",  0x0100, 0x0100, 0x5c8796cc ) /* palette green component */
  792.     ROM_LOAD( "xvi10bpr.6e",  0x0200, 0x0100, 0x3cb60975 ) /* palette blue component */
  793.     ROM_LOAD( "xvi_7bpr.4h",  0x0300, 0x0200, 0x22d98032 ) /* bg tiles lookup table low bits */
  794.     ROM_LOAD( "xvi_6bpr.4f",  0x0500, 0x0200, 0x3a7599f0 ) /* bg tiles lookup table high bits */
  795.     ROM_LOAD( "xvi_4bpr.3l",  0x0700, 0x0200, 0xfd8b9d91 ) /* sprite lookup table low bits */
  796.     ROM_LOAD( "xvi_5bpr.3m",  0x0900, 0x0200, 0xbf906d82 ) /* sprite lookup table high bits */
  797.  
  798.     ROM_REGION( 0x0200, REGION_SOUND1 )    /* sound PROMs */
  799.     ROM_LOAD( "xvi_2bpr.7n",  0x0000, 0x0100, 0x550f06bc )
  800.     ROM_LOAD( "xvi_1bpr.5n",  0x0100, 0x0100, 0x77245b66 )    /* timing - not used */
  801. ROM_END
  802.  
  803. ROM_START( xevios )
  804.     ROM_REGION( 0x10000, REGION_CPU1 )    /* 64k for the first CPU */
  805.     ROM_LOAD( "4.7h",         0x0000, 0x1000, 0x1f8ca4c0 )
  806.     ROM_LOAD( "5.6h",         0x1000, 0x1000, 0x2e47ce8f )
  807.     ROM_LOAD( "xvi_3.2m",     0x2000, 0x1000, 0x79754b7d )
  808.     ROM_LOAD( "7.4h",         0x3000, 0x1000, 0x7033f2e3 )
  809.  
  810.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for the second CPU */
  811.     ROM_LOAD( "xvi_5.3f",     0x0000, 0x1000, 0xc85b703f )
  812.     ROM_LOAD( "xvi_6.3j",     0x1000, 0x1000, 0xe18cdaad )
  813.  
  814.     ROM_REGION( 0x10000, REGION_CPU3 )    /* 64k for the audio CPU */
  815.     ROM_LOAD( "xvi_7.2c",     0x0000, 0x1000, 0xdd35cf1c )
  816.  
  817.     ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  818.     ROM_LOAD( "xvi_12.3b",    0x0000, 0x1000, 0x088c8b26 )    /* foreground characters */
  819.  
  820.     ROM_REGION( 0x2000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  821.     ROM_LOAD( "xvi_13.3c",    0x0000, 0x1000, 0xde60ba25 )    /* bg pattern B0 */
  822.     ROM_LOAD( "xvi_14.3d",    0x1000, 0x1000, 0x535cdbbc )    /* bg pattern B1 */
  823.  
  824.     ROM_REGION( 0x8000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  825.     ROM_LOAD( "xvi_15.4m",    0x0000, 0x2000, 0xdc2c0ecb )    /* sprite set #1, planes 0/1 */
  826.     ROM_LOAD( "16.8d",        0x2000, 0x2000, 0x44262c04 )    /* sprite set #1, plane 2, set #2, plane 0 */
  827.     ROM_LOAD( "xvi_17.4p",    0x4000, 0x2000, 0xdfb587ce )    /* sprite set #2, planes 1/2 */
  828.     ROM_LOAD( "xvi_16.4n",    0x6000, 0x1000, 0x605ca889 )    /* sprite set #3, planes 0/1 */
  829.     /* 0xa000-0xafff empty space to decode sprite set #3 as 3 bits per pixel */
  830.  
  831.     ROM_REGION( 0x4000, REGION_GFX4 )    /* background tilemaps */
  832.     ROM_LOAD( "10.1d",        0x0000, 0x1000, 0x10baeebb )
  833.     ROM_LOAD( "xvi_10.2b",    0x1000, 0x2000, 0xae3ba9e5 )
  834.     ROM_LOAD( "12.3d",        0x3000, 0x1000, 0x51a4e83b )
  835.  
  836.     ROM_REGION( 0x0b00, REGION_PROMS )
  837.     ROM_LOAD( "xvi_8bpr.6a",  0x0000, 0x0100, 0x5cc2727f ) /* palette red component */
  838.     ROM_LOAD( "xvi_9bpr.6d",  0x0100, 0x0100, 0x5c8796cc ) /* palette green component */
  839.     ROM_LOAD( "xvi10bpr.6e",  0x0200, 0x0100, 0x3cb60975 ) /* palette blue component */
  840.     ROM_LOAD( "xvi_7bpr.4h",  0x0300, 0x0200, 0x22d98032 ) /* bg tiles lookup table low bits */
  841.     ROM_LOAD( "xvi_6bpr.4f",  0x0500, 0x0200, 0x3a7599f0 ) /* bg tiles lookup table high bits */
  842.     ROM_LOAD( "xvi_4bpr.3l",  0x0700, 0x0200, 0xfd8b9d91 ) /* sprite lookup table low bits */
  843.     ROM_LOAD( "xvi_5bpr.3m",  0x0900, 0x0200, 0xbf906d82 ) /* sprite lookup table high bits */
  844.  
  845.     ROM_REGION( 0x0200, REGION_SOUND1 )    /* sound PROMs */
  846.     ROM_LOAD( "xvi_2bpr.7n",  0x0000, 0x0100, 0x550f06bc )
  847.     ROM_LOAD( "xvi_1bpr.5n",  0x0100, 0x0100, 0x77245b66 )    /* timing - not used */
  848.  
  849.     ROM_REGION( 0x3000, REGION_USER1 )
  850.     /* extra ROMs (function unknown, could be emulation of the custom I/O */
  851.     /* chip with a Z80): */
  852.     ROM_LOAD( "1.16j",        0x0000, 0x1000, 0x2618f0ce )
  853.     ROM_LOAD( "2.17b",        0x1000, 0x2000, 0xde359fac )
  854. ROM_END
  855.  
  856. ROM_START( sxevious )
  857.     ROM_REGION( 0x10000, REGION_CPU1 )    /* 64k for the first CPU */
  858.     ROM_LOAD( "cpu_3p.rom",   0x0000, 0x1000, 0x1c8d27d5 )
  859.     ROM_LOAD( "cpu_3m.rom",   0x1000, 0x1000, 0xfd04e615 )
  860.     ROM_LOAD( "cpu_2m.rom",   0x2000, 0x1000, 0x294d5404 )
  861.     ROM_LOAD( "cpu_2l.rom",   0x3000, 0x1000, 0x6a44bf92 )
  862.  
  863.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for the second CPU */
  864.     ROM_LOAD( "cpu_3f.rom",   0x0000, 0x1000, 0xd4bd3d81 )
  865.     ROM_LOAD( "cpu_3j.rom",   0x1000, 0x1000, 0xaf06be5f )
  866.  
  867.     ROM_REGION( 0x10000, REGION_CPU3 )    /* 64k for the audio CPU */
  868.     ROM_LOAD( "xvi_7.2c",     0x0000, 0x1000, 0xdd35cf1c )
  869.  
  870.     ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  871.     ROM_LOAD( "xvi_12.3b",    0x0000, 0x1000, 0x088c8b26 )    /* foreground characters */
  872.  
  873.     ROM_REGION( 0x2000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  874.     ROM_LOAD( "xvi_13.3c",    0x0000, 0x1000, 0xde60ba25 )    /* bg pattern B0 */
  875.     ROM_LOAD( "xvi_14.3d",    0x1000, 0x1000, 0x535cdbbc )    /* bg pattern B1 */
  876.  
  877.     ROM_REGION( 0x8000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  878.     ROM_LOAD( "xvi_15.4m",    0x0000, 0x2000, 0xdc2c0ecb )    /* sprite set #1, planes 0/1 */
  879.     ROM_LOAD( "xvi_18.4r",    0x2000, 0x2000, 0x02417d19 )    /* sprite set #1, plane 2, set #2, plane 0 */
  880.     ROM_LOAD( "xvi_17.4p",    0x4000, 0x2000, 0xdfb587ce )    /* sprite set #2, planes 1/2 */
  881.     ROM_LOAD( "xvi_16.4n",    0x6000, 0x1000, 0x605ca889 )    /* sprite set #3, planes 0/1 */
  882.     /* 0xa000-0xafff empty space to decode sprite set #3 as 3 bits per pixel */
  883.  
  884.     ROM_REGION( 0x4000, REGION_GFX4 )    /* background tilemaps */
  885.     ROM_LOAD( "xvi_9.2a",     0x0000, 0x1000, 0x57ed9879 )
  886.     ROM_LOAD( "xvi_10.2b",    0x1000, 0x2000, 0xae3ba9e5 )
  887.     ROM_LOAD( "xvi_11.2c",    0x3000, 0x1000, 0x31e244dd )
  888.  
  889.     ROM_REGION( 0x0b00, REGION_PROMS )
  890.     ROM_LOAD( "xvi_8bpr.6a",  0x0000, 0x0100, 0x5cc2727f ) /* palette red component */
  891.     ROM_LOAD( "xvi_9bpr.6d",  0x0100, 0x0100, 0x5c8796cc ) /* palette green component */
  892.     ROM_LOAD( "xvi10bpr.6e",  0x0200, 0x0100, 0x3cb60975 ) /* palette blue component */
  893.     ROM_LOAD( "xvi_7bpr.4h",  0x0300, 0x0200, 0x22d98032 ) /* bg tiles lookup table low bits */
  894.     ROM_LOAD( "xvi_6bpr.4f",  0x0500, 0x0200, 0x3a7599f0 ) /* bg tiles lookup table high bits */
  895.     ROM_LOAD( "xvi_4bpr.3l",  0x0700, 0x0200, 0xfd8b9d91 ) /* sprite lookup table low bits */
  896.     ROM_LOAD( "xvi_5bpr.3m",  0x0900, 0x0200, 0xbf906d82 ) /* sprite lookup table high bits */
  897.  
  898.     ROM_REGION( 0x0200, REGION_SOUND1 )    /* sound PROMs */
  899.     ROM_LOAD( "xvi_2bpr.7n",  0x0000, 0x0100, 0x550f06bc )
  900.     ROM_LOAD( "xvi_1bpr.5n",  0x0100, 0x0100, 0x77245b66 )    /* timing - not used */
  901. ROM_END
  902.  
  903.  
  904.  
  905. static void init_xevios(void)
  906. {
  907.     int A,i;
  908.  
  909.  
  910.     /* convert one of the sprite ROMs to the format used by Xevious */
  911.     for (A = 0x2000;A < 0x4000;A++)
  912.     {
  913.         int bit[8];
  914.         unsigned char *RAM = memory_region(REGION_GFX3);
  915.  
  916.         /* 76543210 -> 13570246 bit rotation */
  917.         for (i = 0;i < 8;i++)
  918.             bit[i] = (RAM[A] >> i) & 1;
  919.  
  920.         RAM[A] =
  921.             (bit[6] << 0) +
  922.             (bit[4] << 1) +
  923.             (bit[2] << 2) +
  924.             (bit[0] << 3) +
  925.             (bit[7] << 4) +
  926.             (bit[5] << 5) +
  927.             (bit[3] << 6) +
  928.             (bit[1] << 7);
  929.     }
  930.  
  931.     /* convert one of tile map ROMs to the format used by Xevious */
  932.     for (A = 0x0000;A < 0x1000;A++)
  933.     {
  934.         int bit[8];
  935.         unsigned char *RAM = memory_region(REGION_GFX4);
  936.  
  937.         /* 76543210 -> 37512640 bit rotation */
  938.         for (i = 0;i < 8;i++)
  939.             bit[i] = (RAM[A] >> i) & 1;
  940.  
  941.         RAM[A] =
  942.             (bit[0] << 0) +
  943.             (bit[4] << 1) +
  944.             (bit[6] << 2) +
  945.             (bit[2] << 3) +
  946.             (bit[1] << 4) +
  947.             (bit[5] << 5) +
  948.             (bit[7] << 6) +
  949.             (bit[3] << 7);
  950.     }
  951. }
  952.  
  953.  
  954.  
  955. GAME( 1982, xevious,  0,       xevious, xevious,  0,      ROT90, "Namco", "Xevious (Namco)" )
  956. GAME( 1982, xeviousa, xevious, xevious, xeviousa, 0,      ROT90, "Namco (Atari license)", "Xevious (Atari)" )
  957. GAME( 1983, xevios,   xevious, xevious, xevious,  xevios, ROT90, "bootleg", "Xevios" )
  958. GAME( 1984, sxevious, xevious, xevious, sxevious, 0,      ROT90, "Namco", "Super Xevious" )
  959.